<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>财务信息管理</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="../../../bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">

    <style>
        .bootstrap-table {
            padding: 20px;
        }
        #save {
            margin-left: 50px;
            width: 100px;
        }
        .start, .end {
            width: 160px;
        }
    </style>
</head>

<body>
    <div class="tabe_div">
        <p class="text_ient">
          <a class="find_a">报考类型：</a>
          <select class="form_select" style="padding-left: 1%;" id="type">
              <option value="">全部</option>
              <option value="education">学历提升</option>
              <option value="occupation">职业技能</option>
              <option value="title">职称评审</option>
              <option value="train">执业资格</option>
          </select>
          <!-- <a class="find_a">业务进度：</a>
            <select class="form_select" style="padding-left: 1%;" id="businessProgress">
                <option value="">全部</option>
                <option value="0">报考</option>
                <option value="1">退款</option>
                <option value="2">分期缴费</option>
            </select> -->
            <a class="find_a">日期范围：</a>
            <input id="start" class="fee-time form_input text_ient start" type="date" value="" />
            -
            <input id="end" class="fee-time form_input text_ient end" type="date" value="" />
            <a class="find_a">业务小组：</a>
            <select class="form_select" style="padding-left: 1%;" id="group">

            </select>
            <a class="find_a">学生姓名：</a>
            <input type="text" id="name" class="form_input text_ient" placeholder="输入学生姓名" />
            <p class="p_line text_ient">
                <a class="find_a">老师姓名：</a>
                <input id="teacherName" type="text" class="form_input text_ient" placeholder="请输入老师姓名" />
                <input type="button" value="查询" class="but_find" id="search" />
                <input type="button" value="导出" class="but_find" id="export" />
            </p>
        </p>
        <table data-url="json/data_alae_list.json" id="table" class="table_style" style="margin: 0 auto; white-space: nowrap;">
        </table>
    </div>
    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../js/date/js/laydate.js"></script>
    <script src="../../../bstable/js/bootstrap.min.js"></script>
    <script src="../../../bstable/js/bootstrap-table.js"></script>
    <script src="../../../bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../../layer_v2.1/layer/layer.js"></script>
    <script type="text/javascript">
        localStorage.setItem('name', '财务管理/业绩清单')

        queryGroup()
        //查询业务小组
        function queryGroup(obj) {
            $.ajax({
                url: baseUrl + "businessdirector/listAll",
                method: "Post",
                headers: {
                    "Authorization": JSON.parse(localStorage.getItem('userInfo')).token
                },
                data: "",
                success: function (data) {
                    var html_ = "<option value=\"\">请选择</option>";
                    for (var i = 0; i < data.data.length; i++) {
                        var item = data.data[i];
                        html_ += "<option  value=\"" + item.id + "\" >" + item.businessTeam +
                            "</option>";
                    }
                    $("#group").html(html_);
                }
            })
        }

        $(function() {
            $('#search').on('click', function() {
                $('#table').bootstrapTable('refresh')
            })

            $('#export').on('click', function() {
                // const userId = JSON.parse(localStorage.getItem('userInfo')).userId;
                var trainType = $('#type').val()
                var startDate = $('#start').val()
                var endDate = $('#end').val()
                // var businessProgress = $('#businessProgress').val()
                var businessId = $('#group').val()
                var studentName = $('#name').val()
                var teacherName = $('#teacherName').val()
                // var userType = 'caiwu'
                // var offset = params.offset / params.limit
                window.open(`${baseUrl}performance/resultsListSheetExport?trainType=${trainType}&startDate=${startDate}&endDate=${endDate}&businessId=${businessId}&studentName=${studentName}&teacherName=${teacherName}`)
            })

            var perm = JSON.parse(localStorage.getItem('userInfo')).perm
            $('#table')
                .bootstrapTable({
                    method: "get",
                    striped: true,
                    singleSelect: false,
                    url: baseUrl + 'performance/selectResultsList',
                    dataType: "json",
                    sidePagination: "server",
                    pagination: true, //分页
                    pageSize: 10,
                    pageNumber: 1,
                    // rowStyle:rowStyle,
                    search: false, //显示搜索框
                    contentType: "application/x-www-form-urlencoded",
                    ajaxOptions:{
                        headers: {"Authorization": JSON.parse(localStorage.getItem('userInfo')).token}
                    },
                    queryParams: function(params) {
                        params.trainType = $('#type').val()
                        params.startDate = $('#start').val()
                        params.endDate = $('#end').val()
                        params.businessProgress = $('#businessProgress').val()
                        params.businessId = $('#group').val()
                        params.studentName = $('#name').val()
                        params.teacherName = $('#teacherName').val()
                        // params.userType = 'caiwu'
                        params.offset = params.offset / params.limit
                        delete params.order
                        return params
                    },
                    responseHandler: function(res) {
                        console.log(res)
                        var list = res.data.result.records
                        // var maps = {
                        //     "education": '学历提升',
                        //     "occupation": '职业技能',
                        //     "title": '职称评审',
                        //     "train": '执业资格'
                        // }
                        // list.forEach(function(item, i) {
                        //     item.trainType = maps[item.trainType];
                        //     !item && (list[i] = {});
                        //     item.feeFlag = item.feeFlag == 1 ? '已缴费' : '未缴费'
                        // })

                        return {
                            rows: list,
                            total: res.data.total
                        }
                    },
                    columns: [
                    {
                        field: 'no',
                        title: '序号',
                        sortable: true,
                        align: "center",
                        formatter: function(value, row, index) {
                            var pageSize = $('#table').bootstrapTable('getOptions').pageSize;
                            var pageNumber = $('#table').bootstrapTable('getOptions').pageNumber;
                            return pageSize * (pageNumber - 1) + index + 1;
                        }
                    },{
                        title: '姓名',
                        field: 'studentName',
                        align: 'center',
                        valign: 'middle'
                    }, {
                        title: '手机号',
                        field: 'studentMobile',
                        align: 'center'
                    }, {
                        title: '收入/退款',
                        field: 'incomeFlag',
                        align: 'center'
                    }, {
                        title: '业绩',
                        field: 'performance',
                        align: 'center'
                    }, {
                        title: '业务小组',
                        field: 'supervisorsName',
                        align: 'center'
                    }, {
                        title: '招生老师',
                        field: 'teacherName',
                        align: 'center'
                    }, {
                        title: '创建日期',
                        field: 'createDate',
                        align: 'center'
                    }, {
                        title: '报名项目',
                        field: 'applyProject',
                        align: 'center'
                    }, {
                        title: '专业',
                        field: 'major',
                        align: 'center'
                    }, {
                        title: '总费用',
                        field: 'allFee',
                        align: 'center'
                    }, {
                        title: '费用1',
                        field: 'amount',
                        align: 'center'
                    }, {
                        title: '费用2',
                        field: 'amount2',
                        align: 'center'
                    }, {
                        title: '费用3',
                        field: 'amount3',
                        align: 'center'
                    }, {
                        title: '费用4',
                        field: 'amount4',
                        align: 'center'
                    }, {
                        title: '剩余费用',
                        field: 'remainingCost',
                        align: 'center'
                    }, {
                        title: '优惠费用',
                        field: 'preferentialFee',
                        align: 'center'
                    }, {
                        title: '实缴费用',
                        field: 'realPayFee',
                        align: 'center'
                    }, {
                        title: '其他费用',
                        field: 'otherFee',
                        align: 'center'
                    }, {
                        title: '报考类型',
                        field: 'trainType',
                        align: 'center'
                    }]
                });
        });


        function remove(id, idNo, flag) {
            window.location.href = './money.html?type=look&from=jiaofei&id=' + id + '&idNo=' + idNo + '&flag=' + flag
        }

        // function rowStyle(item, index) {
        //     style = item.colorFlag == 1 ? {css:{'color':'#ed5565'}} : {}           
        //     return style;
        // }
    </script>
</body>

</html>